package com.hbnu.list;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class HashMapDemo1 {
    public static void main(String[] args) {
        Map<String, String> hashMap = new HashMap<>();

        hashMap.put("key","value");     //键不能是中文
        hashMap.put("moon","she");

        System.out.println(hashMap);

        Set<String> keys = hashMap.keySet();     //获取所有的键，
        for (String key : keys) {
            String value = hashMap.get(key);
            System.out.println("key:"+key+"\tvalue:"+value);
        }

        Collection<String> values = hashMap.values();       //获取集合中的所有的值
        for (String value : values) {
            System.out.println(value);
        }
    }
}
